<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>自选基金</title>
    <base th:href="@{/}">
    <link href="inspinia/css/bootstrap.min.css" rel="stylesheet">
    <link href="inspinia/font-awesome/css/font-awesome.css" rel="stylesheet">

    <link href="inspinia/css/animate.css" rel="stylesheet">
    <link href="inspinia/css/style.css" rel="stylesheet">
    <link type="text/css" rel="stylesheet" href="inspinia/css/plugins/bootstrap-dialog/bootstrap-dialog.min.css"/>

</head>

<body class="black-bg"
 style=" width: 100%; display: flex;
            flex-direction: column;
            justify-content: flex-start;
            align-items:center;">

<div class="middle-box text-center loginscreen animated fadeInDown">
    <div>
        <div>

            <h1 class="logo-name">M&nbsp;&nbsp;y&nbsp;&nbsp;&nbsp;F&nbsp;&nbsp;o&nbsp;&nbsp;u&nbsp;&nbsp;
                n&nbsp;&nbsp;d&nbsp;&nbsp;a&nbsp;&nbsp;t&nbsp;&nbsp;i&nbsp;&nbsp;o&nbsp;&nbsp;n</h1>

        </div>
        <h3>基金速查!</h3>
        <p>SpringBoot+Mybatis+BootStrap3+Thymeleaf+phantomjs+ajax+token
            <!--Continually expanded and constantly improved Inspinia Admin Them (IN+)-->
        </p>
        <p>登录</p>
        <form class="m-t" role="form" action="#">
            <div class="form-group">
                <input type="text" class="form-control" id="name" name="name" placeholder="用户名" disabled="disabled" required="">
            </div>
            <div class="form-group">
                <input type="password" id="password" name="password" class="form-control" placeholder="密码" disabled="disabled" required="">
            </div>
            <button id="btnLogin" type="button" class="btn btn-danger block full-width m-b" disabled="disabled">原版本已经停用</button>
            <button id="btnvue3" type="button" class="btn btn-primary block full-width m-b">点我切换到VUE3版本</button>

<!--            <a href="#"><small>忘记密码?</small></a>-->
<!--            <p class="text-muted text-center"><small>没有账号?</small></p>-->
<!--            <a class="btn btn-sm btn-white btn-block" href="register.html">创建一个账号</a>-->
        </form>
        <p class="m-t"><small>Inspinia we app framework base on Bootstrap 3 &copy; 2020</small></p>
    </div>
</div>
<a style="display:none;" id="lnktz"
   th:href="${#httpServletRequest.getContextPath()}
   +'/foundation/foundation_detail_pictures'">加载中。。。</a>
<a style="display:none;" id="lnkvue3"
   th:href="${#httpServletRequest.getContextPath()}
   +'/foundation/foundation_vue3'">加载中。。。</a>

<!-- Mainly scripts -->
<script src="inspinia/js/jquery-3.1.1.min.js"></script>
<!--<script src="inspinia/js/popper.min.js"></script>-->
<script src="inspinia/js/bootstrap.js"></script>

<!--bootstrap-dialog start-->
<script type="text/javascript" src="inspinia/js/plugins/bootstrap-dialog/bootstrap-dialog.min.js"></script>
<!--bootstrap-dialog end-->

<!-- 该通用脚本放在最后 -->
<script type="text/javascript" src="inspinia/js/Common.js"></script>
<script>
    $(document).ready(function () {

        $("#btnvue3").click(function () {
            document.getElementById("lnkvue3").click();

        });
        $("#btnLogin").click(function () {

            if ($('#name').val() == "") {
                alert("用户名不能为空！", BootstrapDialog.TYPE_DANGER);
                return;
            }
            if ($('#password').val() == "") {
                alert("密码不能为空！", BootstrapDialog.TYPE_DANGER);
                return;
            }

            $.ajax({
                // 提交数据的类型 POST GET
                type: "Get",
                // 提交的网址
                url: "user/login",
                // 提交的数据
                data: {
                    name: $('#name').val(),
                    password: $('#password').val(),
                },
                // 返回数据的格式
                datatype: "json",
                // 在请求之前调用的函数
                // beforeSend: xmlBeforeSend,
                // 成功返回之后调用的函数
                success: function (data) {
                    //$.fn.jqLoading("destroy");

                    if (data != null && data.result == "success") {

                        if(typeof(Storage) == "undefined"){
                            alert('This browser supports localStorage');
                        }else{
                            window.localStorage.setItem("token", data.token);
                            document.getElementById("lnktz").click();
                        }


                        // if (data.fcode != "") {
                        //     // var href = $("#lnktz").attr("href");
                        //     // href = href + data.fcode;
                        //     // $("#lnktz").attr("href", href);
                        //     document.getElementById("lnktz").click();
                        // }
                        // else{
                        //     document.getElementById("lnktz").click();
                        // }


                    } else {
                        alert(data.message, BootstrapDialog.TYPE_DANGER);
                    }
                }//,
                // 调用出错执行的函数
                //error: xmlError
            });
        });


    });

</script>

</body>

</html>
